<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>DOM</title>
</head>

<body>
    <script type="text/javascript">
    function Elem() {
        this.elem = document.getElementById(id);
    }
Elem.prototype.html = function (val) {
	var elem = this.elem;
	if(val) {
		elem.innerHTML = val;
		return this;//链式操作
	}else {
		return elem.innerHTML;
	}
}

Elem.prototype.on = function (type, fn) {
	var elem = this.elem
}

    var div1 = new Elem('div1')
    div1.html ('<p>hello imooc</p>')
    div.on('click',function () {
    	alert('clicked')
    }) 

    // 链式操作模式  
    // div1.html ('<p>hello imooc</p>').on('click',function () {
    // 	alert('clicked')
    // }) 
    </script>
</body>

</html>